package com.higgins.eventtracking.client.finance;

import java.util.Date;
import java.util.List;
import java.util.logging.Logger;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.DockLayoutPanel.Direction;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.higgins.eventtracking.client.AssetTrackingService;
import com.higgins.eventtracking.client.AssetTrackingServiceAsync;
import com.higgins.eventtracking.client.FinanceTrackingService;
import com.higgins.eventtracking.client.FinanceTrackingServiceAsync;
import com.higgins.eventtracking.client.SecurityAccessDeniedException;
import com.higgins.eventtracking.client.dto.AssetDTO;
import com.higgins.eventtracking.client.dto.TransactionDTO;
import com.higgins.eventtracking.server.GenericDataStoreService;

public class Assets extends VerticalPanel		{
	private static final Logger log = Logger.getLogger(Assets.class.getName());
	private AssetGenericColumns assetColumns = null;
	private AssetGenericTable assetTable = null;
	private final AssetTrackingServiceAsync assetTrackingService = GWT
		.create(AssetTrackingService.class);
	private ScrollPanel scrollPanel = null;
	private boolean firstRun = true;
	
	public Assets()			{
	}
	
	public void update()	{
		if (firstRun)	{
			initialise();
		} else {
			refresh();
		}
	}
	
	public void initialise()	{
//		firstRun = false;
		clear();
		assetColumns = new AssetGenericColumns();
		assetTable = new AssetGenericTable(assetColumns);
		scrollPanel = new ScrollPanel();
		scrollPanel.add(assetTable);
		scrollPanel.setHeight("600px");
		add(scrollPanel);
		/*
		try {
			assetTrackingService.retrieveAssets(new AsyncCallback<List<AssetDTO>>()	{
					@Override
					public void onFailure(Throwable caught) {
						log.info("Transactions: " + caught.toString());
					}

					@Override
					public void onSuccess(List<AssetDTO> result) {
						assetTable.update(result);
					}
				});
		} catch (IllegalArgumentException e) {
			log.info("Transactions: " + e.toString());
		} 	
		*/
	}
	public void refresh()	{
		
	}
}
